export const globalfun = {
	previewImage(list, index) {
		uni.previewImage({
			current: index,
			urls: list,
			longPressActions: {
				itemList: ['发送给朋友', '保存图片', '收藏'],
				success: function(data) {
					console.log('选中了第' + (data.tapIndex + 1) + '个按钮,第' + (data.index + 1) + '张图片');
				},
				fail: function(err) {
					console.log(err.errMsg);
				}
			}
		});
	},
	// 用于没有入圈是执行此方法
	pageApply:data=>{
		uni.showModal({
			title:'系统提示',
			content: '此功能需要入圈后访问！',
			confirmText:'申请入圈',
			confirmColor:'#0756FF',
			success: (res) => {
				if (res.confirm) {
					uni.navigateTo({
						url:'/pages/user/apply'
					})
				} else if (res.cancel) {}
			}
		});
	},
	pageGoTs: url => {
		uni.switchTab({
			url
		})
	},
	pageGo: url => {
		uni.navigateTo({
			url
		})
	},
	phoneCall: number => {
		if(uni.getStorageSync('cirleToken')){
			if(uni.getStorageSync('user').level==2){
				uni.makePhoneCall({
					phoneNumber: number, //仅为示例
					success: function() {
						console.log('success');
					}
				});
			}else{
				uni.showModal({
					title:'系统提示',
					content: '您非正式会员，暂无查看权限！',
					confirmText:'确认',
					confirmColor:'#0756FF',
					showCancel:false,
					success: (res) => {
						if (res.confirm) {
						} else if (res.cancel) {}
					}
				});
			}
			
		}else{
			uni.navigateTo({
				url: '/pages/login/login'
			})
		}
		
	},
	opennavigation: data => {
		console.log(data.split(',')[0]);
		uni.openLocation({
			latitude: parseFloat(data.split(',')[0]),
			longitude: parseFloat(data.split(',')[1]),
			success: function() {
				console.log('success');
			}
		});
	},
	copyFun: (text,message) => {
		if(uni.getStorageSync('cirleToken')){
			if(uni.getStorageSync('user').level==2){
				uni.setClipboardData({
					data:text, // 要复制的内容
					success: () => { // 复制成功回调
						uni.showToast({
							title:message,
							icon: 'success'
						})
					}
				});
			}else{
				uni.showModal({
					title:'系统提示',
					content: '您非正式会员，暂无查看权限！',
					confirmText:'确认',
					confirmColor:'#0756FF',
					showCancel:false,
					success: (res) => {
						if (res.confirm) {
						} else if (res.cancel) {}
					}
				});
			}
			
		}else{
			uni.navigateTo({
				url: '/pages/login/login'
			})
		}
		
	},
}